import { Button, Drawer, Radio, Space } from 'antd';
import type { DrawerProps } from 'antd/es/drawer';
import type { RadioChangeEvent } from 'antd/es/radio';
import React, { useState } from 'react';
import AFROM from '../AFROM';
import { FC } from "react";


const ADrawer: FC<{
    fn:(value:any)=>void
}> = ({fn}) => {
    const [visible, setVisible] = useState(false);
    const [placement, setPlacement] = useState<DrawerProps['placement']>('right');

    const showDrawer = () => {
        setVisible(true);
    };

    const onChange = (e: RadioChangeEvent) => {
        setPlacement(e.target.value);
    };

    const onClose = () => {
        setVisible(false);
    };

    return (
        <>
            <Space>

                <Button type="primary" onClick={showDrawer}>
                    +新建
                </Button>
            </Space>
            <Drawer
                title="新建知识库"
                placement={placement}
                width={500}
                onClose={onClose}
                visible={visible}
            >
                <AFROM fn={fn}></AFROM>
            </Drawer>
        </>
    );
};

export default ADrawer;